package iac.gwt.webuser.client.role;

import iac.gwt.client.IacListPanel;
import br.com.iswe.gwt.ui.client.BeanMap;
import br.com.iswe.gwt.ui.client.CheckBoxBag;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class XXX_ListPanel extends RmListPanel {
	
	protected FlexTable flexTable;

	public XXX_ListPanel(){
		flexTable = new FlexTable();
		initWidget(flexTable);
		
		flexTable.setWidget(0, 1, createColumnHeader("XXX_", "xXX_Id"));
		flexTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
		
		setupScreen();
	}
	
	public void setupScreen() {
		super.setupScreen();
	}
	
	protected FlexTable getFlexTable() {
		return flexTable;
	}
	
	@SuppressWarnings("unchecked")
	protected void buildRow(int row, final BeanMap item) {
		if(isCheckBoxesEnabled()){
			//check box
			CheckBoxBag checkBox = new CheckBoxBag(item);
			checkBoxList.add(checkBox);
			flexTable.setWidget(row, 0, checkBox );
		}
		if(isLinkEnabled()){
			//XXX_
			Hyperlink link = new Hyperlink(item.getString("XXX_"), "DETAIL");
			link.addClickHandler(new ClickHandler(){
				public void onClick(ClickEvent event) {
					onSelectListener.fire(item);
				}
			});
			flexTable.setWidget(row, 1, link);
		}
		else{
			//XXX_
			flexTable.setWidget(row, 1, new Label( item.getString("XXX_") ));
		}
		
		//description
		
	}

}
